package com.system.core.plugins.mybatis.custom;

import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.JavaVisibility;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.Parameter;

import lombok.experimental.UtilityClass;

@UtilityClass
public class MyInsertInterface {

	public Method insertBatchMethod(IntrospectedTable introspectedTable) {
		Method batchInsert = new Method("insertBatch");
		Parameter batchInsertParam = new Parameter(new FullyQualifiedJavaType("List<"+introspectedTable.getBaseRecordType()+">"),"list");
		
		batchInsert.addParameter(batchInsertParam);
		batchInsert.setVisibility(JavaVisibility.PUBLIC);
		batchInsert.addJavaDocLine("/**");
		batchInsert.addJavaDocLine(" * @mbg.generated");
		batchInsert.addJavaDocLine(" * 批量插入");
		batchInsert.addJavaDocLine(" */");
		batchInsert.setAbstract(true);
		batchInsert.setReturnType(new FullyQualifiedJavaType("int"));
		return batchInsert;
	}
	
	public Method insertIgnoreBatch(IntrospectedTable introspectedTable) {
		Method batchIgnoreInsert = new Method("insertIgnoreBatch");
		Parameter batchInsertParam = new Parameter(new FullyQualifiedJavaType("List<"+introspectedTable.getBaseRecordType()+">"),"list");
		batchIgnoreInsert.addParameter(batchInsertParam);
		batchIgnoreInsert.setVisibility(JavaVisibility.PUBLIC);
		batchIgnoreInsert.addJavaDocLine("/**");
		batchIgnoreInsert.addJavaDocLine(" * @mbg.generated");
		batchIgnoreInsert.addJavaDocLine(" * 批量插入");
		batchIgnoreInsert.addJavaDocLine(" */");
		batchIgnoreInsert.setAbstract(true);
		batchIgnoreInsert.setReturnType(new FullyQualifiedJavaType("int"));
		return batchIgnoreInsert;
	}
}
